<%@ taglib uri="http://www.springframework.org/tags" prefix="s"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="sf"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<html>
<head>
<%@ include file="html-header.jsp"%>
<script type="text/javascript">
<%@ include file="../js/pagingOrders.js" %>
</script>
<style type="text/css">
<%@ include file="../stylesheets/main.css"%>
<%@ include file="../stylesheets/header.css"%>
<%@ include file="../stylesheets/footer.css"%>
<%@ include file="../stylesheets/indexContent.css"%>
<%@ include file="../stylesheets/carousel.css"%>
<%@ include file="../stylesheets/orders.css"%>
</style>
</head>
<body>
	<div id="left-column-outer">
		<div id="left-column"></div>
	</div>

	<div id="center-column">
		<div class="CenteredContainer">
			<img id="background_noresize" alt="background_noresize"
				src="/Browarex/img/background.jpg">
			<%@ include file="header.jsp"%>
			<div class="ContentShade"></div>
			<div class="ContentContainer">	
				<div>
					<span class="ProductTableDesc"><s:message code="label.zamowienia"/></span>
		    		<div style="position: absolute; right: 60px;">
			    		<span>Sposob wyswietlania:</span>
			    		<input id="interfaceGroups" type="radio" name="orderInterfaceType" value="Groups" checked="true" onclick="javascript: groupAll('beerTableNavPos','beerQueryResults')" >Grupowanie</input>
			    		<input type="radio" id="interfaceNoGroups" name="orderInterfaceType" value="NoGroups" onclick="javascript: unGroupAll('beerTableNavPos','beerQueryResults')")/>Bez grupowania</input>
		    		</div>
				</div>
				<div id="orderTableContainer">											
											
				    <table class="det" id="beerQueryResults">			        
		            	<c:forEach items="${orders}" var="order" varStatus="exLoop">
						    <tr class="page${exLoop.index} ordersTitle"> 
							    <td colspan="3">
			   						<span class="ProductOrderStatus">Zamowienie z <fmt:formatDate value="${order.orderDate}" type="both" timeStyle="short" dateStyle="short"/><br/>Status: <span style="color:limegreen;">${order.orderState.value}</span></span>
			   						<c:if test="${order.orderState == 'REALIZED'}"> 				            
										<sf:form method="get" commandName="order" action="facture" modelAttribute="order" style="position: relative; right: 45px; top: -75px;">
											<sf:hidden path="id" value="${order.id}" /> 
											<input type="submit" value="<s:message code="button.faktura"/>" style="height:45px; position:absolute; right: 0; font-size: large;">			
										</sf:form>										
						            </c:if>
	   							</td>
							</tr>  
							<tr class="page${exLoop.index} ordersRow">   
					            <c:forEach items="${order.productList}" var="product" varStatus="loop"> 
						            <c:if test="${not loop.first and loop.index % 3 == 0}"> 				            
						                </tr>
						                    <tr class="page${exLoop.index} ordersRow">
						            </c:if>
						            <td class="ProductTableCell">
							            <div>
							            	<img class="BeerImage" alt="Beer Image" src="getImage?imageId=${product.id}"/>
							            	<span class="ProductInfo Title">${product.productName} </span>
											<span class="ProductInfo Capacity">${product.product.capacity}l</span>
											<span class="ProductInfo Voltage">; ${product.product.voltage}%</span> <br /> 
											<span class="ProductInfo Quanitiy">Sztuk: ${product.quantity}</span><br /> 
											<span class="ProductInfo Type">${product.product.packageType.value}</span><br />											
										</div>
									</td>
			          			</c:forEach>	
		          			</tr>
		          			<tr class="page${exLoop.index} ordersButton">
		          			<td>
		          			
		          			</td>
		          			</tr>
		          		</c:forEach>
		           	</table>
	           	</div>
	           	<div id="beerTableNavPos"></div>
			</div>
			<%@ include file="footer.jsp"%>
		</div>
	</div>

	<div id="right-column-outer">
		<div id="right-column"></div>
	</div>
</body>
</html>
<script type="text/javascript"><!--
    var pager = new PagerOrders('beerQueryResults', 4); 
    pager.init(); 
    pager.showPageNav('pager', 'beerTableNavPos'); 
    pager.showPage(1);
//--></script>